﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Configuration;

namespace WebApplication1
{
    public partial class addcd : System.Web.UI.Page
    {
        SqlConnection cnn=new SqlConnection(WebConfigurationManager.AppSettings["connect"]);
        protected void Page_Load(object sender, EventArgs e)
        {
            txtprice.Text = Convert.ToString(0);
        }
        
        protected void regbtn_Click(object sender, EventArgs e)
        {
            int p;
            if (txtprice.Text.Equals('0'))
                p = 0;
            else
                p = Convert.ToInt16(txtprice.Text);

            cnn.Open();
            SqlCommand cmd = new SqlCommand("insert into cdinfo values('" + txtcdno.Text + "','" + txtcdname.Text + "','" + txtcat.Text + "','" + txtlang.Text + "','" + txtpub.Text + "','" + txtyr.Text + "','" + txtcopies.Text + "'," + p+ ")", cnn);
            cmd.ExecuteNonQuery();
            cnn.Close();
            Response.Redirect("~/Admin/default1.aspx");
        }
    }
}